feat(platform): sandbox tx boundary · gantt tree schema · formula date math · RLS §7.3.1#2039
Merged
Merged
Conversation
…math, RLS §7.3.1 Four platform enhancements surfaced by a real eHR/MES dogfood: - runtime/objectql/spec: ctx.api.transaction() — transaction boundary for sandboxed hook/action bodies (explicit handle threading across the deferred-promise pump; rollback on throw or timeout). New api.transaction capability. - spec: extend GanttConfigSchema with the 11 fields the renderer already supports (parentField tree, baselines, resourceView, quickFilters, …) so the metadata pipeline stops stripping them at the spec boundary. - formula: addDays/addMonths CEL stdlib functions (UTC, dyn-typed, addMonths clamps to month end). - spec/plugin-security: converge the RLS contract to the four expression forms the compiler implements (drop the over-promised subquery/LIKE/regex/ ANY/ALL surface) and wire §7.3.1 dynamic membership via a pre-resolved ExecutionContext.rlsMembership bag; recognize "1 = 1" as always-true so RLS.allowAllPolicy grants instead of failing closed.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…s-7b232d # Conflicts: # packages/spec/src/ui/view.test.ts # packages/spec/src/ui/view.zod.ts
Contributor
📓 Docs Drift CheckThis PR changes 5 package(s): 98 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
用真实 eHR/MES 生产项目作磨刀石,补齐 ObjectStack 平台四处能力缺口。每项都以"扩 schema / 接契约"为主,向后兼容(新增字段全 optional)。
改动
①
ctx.api.transaction(P0) —@objectstack/{spec,objectql,runtime}沙箱 hook/action body 内的事务边界:
ctx.api.transaction(async () => { … }),回调内所有ctx.api读写跑在同一个 driver 事务里,返回即 commit、抛错即 rollback、超时残留事务在 dispose 前兜底 rollback。api.transactioncapability token。ScopedContext增加beginTransaction()/commitTransaction(handle)/rollbackTransaction(handle)原语,handle 显式穿线(resolveTx优先于 ambienttxStore),因为沙箱跨多个事件循环 turn 驱动 body、AsyncLocalStorage 上下文活不过setImmediate边界。无事务支持的 driver 退化为非事务执行。ctx.api.transaction,事务内操作走 tx 作用域上下文。② Gantt 扩 schema(P0) —
@objectstack/specGanttConfigSchema补上渲染器早已支持、却被 spec 边界z.object静默剥掉的 11 个字段:parentField(项目→产品→排产计划→派工单 4 级树)、typeField、baselineStart/EndField、resourceView+assignee/effort/capacity、quickFilters、tooltipFields等。原 5 字段不变,全部新增 optional。③ formula 日期运算 —
@objectstack/formulaCEL stdlib 新增
addDays(date, n)/addMonths(date, n)(UTC;n为dyn规避 record number 字段以 double 到达时的no such overload#1928;addMonths钳到目标月末:Jan 31 +1mo → Feb 28)。④ RLS 收敛文档 + 接 §7.3.1(P1) —
@objectstack/{spec,plugin-security}rls.zod.ts从"承诺通用 SQL"收敛到编译器真正实现的 4 种形式(field = current_user.<prop>/field = 'literal'/field IN (current_user.<array>)/1 = 1),删除过度承诺的subquery / AND·OR·NOT / LIKE·ILIKE / regex / ANY·ALL / NOT IN / IS NULL / NOW()表面,显式写明 fail-closed。org_user_ids泛化为ExecutionContext.rlsMembership: Record<string, string[]>预解析成员袋(团队/辖区/共享记录);编译器把各键并入 user context(仅数组、不覆盖具名字段),于是任意field IN (current_user.<key>)都能解析、空集仍 fail-closed。顺手把1 = 1识别为 always-true,让RLS.allowAllPolicy名实相符(此前反向 deny-all 暗雷)。验证
@objectstack/spec6566 ✅@objectstack/plugin-security77 ✅(含 5 个新 RLS 测试)@objectstack/runtime395 ✅ ·@objectstack/objectql667 ✅(① 上轮验证)@objectstack/formula129 ✅changesets
sandbox-ctx-api-transaction(spec/objectql/runtime minor)·gantt-config-tree-resource-fields(spec minor)·formula-add-days-months(formula minor)·rls-converge-docs-dynamic-membership(spec/plugin-security minor)后续(不在本 PR)
GanttConfigEx收敛进 specGanttConfig,待@objectstack/spec发版后跟进(已挂 task)。